using Godot;
using System;

public partial class NItem : Area2D
{
	[Export] public CItem mItem;
	TextureRect mImg;
	Vector2 mSize = new Vector2(40, 40);
	// Called when the node enters the scene tree for the first time.
	public override void _Ready()
	{
		mImg = GetNode<TextureRect>("TextureRect");
	}

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{
		if (mItem != null)
		{
			if (!string.IsNullOrEmpty(mItem.mImgPath))
			{
				if (mImg.Texture?.ResourcePath != mItem.mImgPath)
				{
					mImg.Texture = CHelp.loadRes<Texture2D>(mItem.mImgPath);
				}
			}
		}
	}

	public Vector2 ItemSize
	{
		get { return mSize; }
	}
}
